package com.xiaolin.schedule.springboot;

import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @ClassName TestSchedule
 * @Description TODO
 * @Detail detail
 * @Author MyPC
 * @Date 2020/9/27
 * @Version 1.0
 */
@Component
@EnableScheduling   //Spring的任务调度要开启该注解
public class TestSchedule {

    /**
     * Spring自带的任务调度注解
     * 该表达式 0/2 * * * * ? 表示当应用启动后每两秒执行一次该方法
     */
    @Scheduled(cron = "0/2 * * * * ?")
    public void schedule(){
        System.out.println("hello");
    }
}
